#!/bin/bash

###
### Stops the database and Glassfish server, which have to be installed
### using the setup script and started using the start script.
### The application was already deployed using the setup script.
### You need to execute the stop script from the same
### working directory as the setup and start script. 
###
### @Author: Florian Sieck
###

echo "Stopping the server."

if [ -d SimSearch1 ]
then
  pushd SimSearch1 > /dev/null
  if [ -d mysql ] && [ -d glassfish4 ]
  then
    ./glassfish4/glassfish/bin/asadmin stop-domain
    pushd mysql > /dev/null
    ./bin/mysqladmin --defaults-file=".my.cnf" --user=root shutdown
    popd > /dev/null 
  else
    echo "There is no SimSearch1 folder. Did you execute the setup script?"
  fi
  popd > /dev/null
else
  echo "There is no SimSearch1 folder. Did you execute the setup script?"
fi
